package com.module.shici.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.fenghuajueli.libbasecoreui.utils.MyStatusBarUtils;
import com.module.shici.R;
import com.module.shici.adapter.BannerImgAdapter;
import com.module.shici.data.ShiCIData;
import com.module.shici.sql.ShiCi;
import com.youth.banner.Banner;

import java.util.List;

public class MyShiCiActivity extends AppCompatActivity {

    private TextView type;
    private Banner banner;
    private List<ShiCi> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MyStatusBarUtils.setStatusBar(this,"#F6EEE4");
        setContentView(R.layout.module_shici_activity_myshici);
        initData();
        initBanner();
    }

    private void initBanner() {
        //第一个参数 获取数据，第二个获取 从那传过来的值
        BannerImgAdapter bannerImgAdapter = new BannerImgAdapter(ShiCIData.getShiCiByTag(getIntent().getStringExtra("title"),
                getIntent().getIntExtra("type",1)));
        banner.setAdapter(bannerImgAdapter);
        //添加画廊效果
        banner.setBannerGalleryEffect(90, 15);

        bannerImgAdapter.getBannerOnItemClick(new BannerImgAdapter.BannerListener() {
            @Override
            public void onItemClick(String title, String author, String content, String fanyi, String zhushi, String chaodai) {
//                if (PublicFunction.checkCanNext()) {
                    Intent intent = new Intent(MyShiCiActivity.this,ShiCiDetailActivity.class);
                    intent.putExtra("title",title);
                    intent.putExtra("author",author);
                    intent.putExtra("content",content);
                    intent.putExtra("fanyi",fanyi);
                    intent.putExtra("zhushi",zhushi);
                    intent.putExtra("chaodai",chaodai);
                    intent.putExtra("type",type.getText());
                    startActivity(intent);
//                }
            }
        });
    }

    private void initData() {
        findViewById(R.id.shici_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        type = findViewById(R.id.shici_title);
        type.setText(getIntent().getStringExtra("title"));
        banner = findViewById(R.id.shici_banner);
    }
}